﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ControllerManageServer.Packet
{
    /// <summary>
    /// 数据报文信息模型
    /// </summary>
    public class DatagramInfoModel
    {
        /// <summary>
        /// 数据报文
        /// </summary>
        public byte[] Datagram { get; set; }
        /// <summary>
        /// 接收时间
        /// </summary>
        public DateTime ReceiveTime { get; set; }

        /// <summary>
        /// 数据报文是否相等
        /// </summary>
        /// <param name="iDatagram"></param>
        /// <returns></returns>
        public bool DatagramIsEqual(byte[] iDatagram) {
            if (iDatagram == null && Datagram == iDatagram) return true;
            if(iDatagram == null || Datagram == null) return false;
            if(iDatagram.Length != Datagram.Length) return false;
            for(int i = 0; i < iDatagram.Length; i++) {
                if (iDatagram[i] != Datagram[i]) return false;
            }
            return true;
        }
    }
}
